import { Controller, Post, Body, Get, Param, Put, Delete, ParseIntPipe } from '@nestjs/common';
import { MarketingService } from './marketing.service';
import { CreateCouponDto } from './dto/create-coupon.dto';
import { UpdateCouponDto } from './dto/update-coupon.dto';
import { ApiTags, ApiOperation } from '@nestjs/swagger';

@ApiTags('营销-优惠券')
@Controller('coupon')
export class MarketingController {
  constructor(private readonly marketingService: MarketingService) {}

  @Post()
  @ApiOperation({ summary: '创建优惠券' })
  create(@Body() dto: CreateCouponDto) {
    return this.marketingService.create(dto);
  }

  @Get()
  @ApiOperation({ summary: '获取优惠券列表' })
  findAll() {
    return this.marketingService.findAll();
  }

  @Get(':id')
  @ApiOperation({ summary: '获取优惠券详情' })
  findOne(@Param('id', ParseIntPipe) id: number) {
    return this.marketingService.findOne(id);
  }

  @Put(':id')
  @ApiOperation({ summary: '更新优惠券' })
  update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateCouponDto) {
    return this.marketingService.update(id, dto);
  }

  @Delete(':id')
  @ApiOperation({ summary: '删除优惠券' })
  remove(@Param('id', ParseIntPipe) id: number) {
    return this.marketingService.remove(id);
  }
}
